package com.tedu.drugs.controller;

import com.tedu.common.response.JsonResult;
import com.tedu.drugs.pojo.dto.DrugsParam;
import com.tedu.drugs.pojo.dto.DrugsQuery;
import com.tedu.drugs.pojo.vo.DrugsVO;
import com.tedu.drugs.service.DrugsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/medicine/list")
public class DrugsController {

    @Autowired
    DrugsService drugsService;

    @GetMapping("select")
    public JsonResult selectRepair(DrugsQuery drugsQuery){
        log.debug("查询药品：drugsQuery={}",drugsQuery);
        List<DrugsVO> list = drugsService.selectDrugs(drugsQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("insert")
    public JsonResult insertRepair(DrugsParam drugsParam){
        log.debug("录入车辆:repairParam={}",drugsParam);
        drugsService.insertDrugs(drugsParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{medicineId}")
    public JsonResult deleteRepair(@PathVariable Long medicineId){
        log.debug("删除维修车辆：{}",medicineId);
        drugsService.delete(medicineId);
        return JsonResult.ok();
    }


}
